from utils.log_util import logger


def assertCompare(expect, compare, actual):

    logger.info(f"预期结果：{expect} {compare} {actual}")
    try:
        if compare == "==":
            assert expect == actual
        elif compare == "!=":
            assert expect != actual
        elif compare == ">":
            assert expect > actual
        elif compare == "<":
            assert expect < actual
        elif compare=="in":
            assert expect in actual
        else:
            try:
                raise NameError(f"{compare} 断言方式错误")
            except Exception as e:
                logger.info(e)
                raise


        logger.info("断言成功")

    except AssertionError as e:
        logger.info(f"断言失败{e}")
        raise
